package com.ayou.eggguard.farm.service.impl;

import com.ayou.eggguard.farm.mapper.ChickenCoopMapper;
import com.ayou.eggguard.farm.mapper.ChickenFarmMapper;
import com.ayou.eggguard.farm.pojo.ChickenCoop;
import com.ayou.eggguard.farm.pojo.FeedRecord;
import com.ayou.eggguard.farm.service.ChickenCoopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ChickenCoopServiceImpl implements ChickenCoopService {
    @Autowired
    private ChickenCoopMapper chickenCoopMapper;
    @Autowired
    private ChickenFarmMapper chickenFarmMapper;

    @Override
    public ChickenCoop getCoopByNumber(String coopNumber) {
        return chickenCoopMapper.getCoopByNumber(coopNumber);
    }

    @Override
    public void addCoop(String chickenFarmName, ChickenCoop chickenCoop) {
        int id=chickenFarmMapper.getFarmIdByFarmName(chickenFarmName);
        chickenCoopMapper.addCoop(id,chickenCoop);
    }

    @Override
    public void updateCoopInfo(ChickenCoop chickenCoop) {
        chickenCoopMapper.updateCoopInfo(chickenCoop);
    }

    @Override
    public List<ChickenCoop> getCoopsByFarmName(String farmName) {

        return chickenCoopMapper.getCoopsByFarmName(farmName);
    }

    @Override
    public void deleteCoop(String coopNumber) {
        chickenCoopMapper.deleteCoop(coopNumber);
    }

    @Override
    public List<FeedRecord> getFeedRecord(String coopNumber) {
        return chickenCoopMapper.getFeedRecord(coopNumber);
    }
}
